data {
	int<lower=0> M; // The number of pairwise comparisons in the data
	int<lower=0> N; // The number of distinct texts.
	int y_map[M,2]; // Each row corresopnds to a comparison, each entry within a row gives the index of the left and right documents
	int info[M]; // A binary matrix for which document in each comparison was coded as more informational; 1 for left, 0 for right
	int conf[M]; // A binary matrix for which document in each comparison was coded as more confrontationa; 1 for left, 0 for right.
	
}

parameters {
	matrix[N,2] alpha_infoconf; // Each row describes how informational and confrontational each text (partition) is.
	real<lower=-1,upper=1> infoconf_corr; // A parameter that captures the overall correlation between information and confrontation.
}

transformed parameters{
	cov_matrix[2] Sigma_alpha;
	Sigma_alpha = [[1, infoconf_corr], [infoconf_corr, 1]]; // This multivariate normal explicitly measures the correlation betwen information and confrontation.
}

model { // Implements the model from the Estimation subsection.
	infoconf_corr ~ uniform(-1, 1); // The prior for the correlation is completely diffuse.

	for (n in 1:N) {
		alpha_infoconf[n] ~ multi_normal([0, 0], Sigma_alpha);
	}
	
	for (m in 1:M) {
		info[m] ~ bernoulli_logit(alpha_infoconf[y_map[m,1],1] - alpha_infoconf[y_map[m,2],1]);
		conf[m] ~ bernoulli_logit(alpha_infoconf[y_map[m,1],2] - alpha_infoconf[y_map[m,2],2]);
	}
}
